package Zoo.View.ZoomanView;

import Zoo.Entity.ZooparkEntity;
import Zoo.Handler.UpdateZooparkView1Handler;

import javax.swing.*;
import java.awt.*;
import java.sql.Date;

/**
 * 1、UpdateZooparkView1用于动物饲养员修改园区
 */
public class UpdateZooparkView1 extends JDialog {

// UpdateZooparkView1 updateZooparkView1=new UpdateZooparkView1();

    public UpdateZooparkView1(int parkId) {

     //  updateZooparkView1.setParkId(parkId);
       //    this.parkId=parkId;
//        System.out.println(this.parkId+"!!");
//        System.out.println(parkId+"???");
      //  updateZooparkView1.getParkId();
    }

    JPanel jPanel=new JPanel();
    JLabel idLable =new JLabel("修改的园区id");
    JTextField idTxt=new JTextField();
    JLabel kindLable =new JLabel("展区类型");
    JTextField kindTxt=new JTextField();
    JLabel introductionLable =new JLabel("简介");
    JTextField introductionTxt=new JTextField();
    JLabel areaLable =new JLabel("占地面积");
    JTextField areaTxt=new JTextField();
    JLabel addressLable =new JLabel("地址");
    JTextField addressTxt=new JTextField();
    JLabel beginLable =new JLabel("开始时间");
    JTextField beginTxt=new JTextField();
    JLabel finishLable =new JLabel("结束时间");
    JTextField finishTxt=new JTextField();
    JLabel adminidLable =new JLabel("园区管理员id");
    JTextField adminidTxt=new JTextField();
    JButton updateBtn =new JButton("修改");
    UpdateZooparkView1Handler updateZooparkView1Handler;


    public UpdateZooparkView1(ZoomenView zoomenView){
        super(zoomenView,"修改园区信息",true);
        updateZooparkView1Handler=new UpdateZooparkView1Handler(this,zoomenView);


        idLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(idLable);
        idTxt.setPreferredSize(new Dimension(200,30));

//        // //此处是为了让动物饲养员只能修改自己管理的园区
//
//        idTxt.setText(parkId+"");
//        idTxt.setEnabled(false);
        jPanel.add(idTxt);

        kindLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(kindLable);
        kindTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(kindTxt);

        introductionLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(introductionLable);
        introductionTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(introductionTxt);

        areaLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(areaLable);
        areaTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(areaTxt);

        addressLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(addressLable);
        addressTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(addressTxt);

        beginLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(beginLable);
        beginTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(beginTxt);

        finishLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(finishLable);
        finishTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(finishTxt);

        adminidLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(adminidLable);
        adminidTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(adminidTxt);

        Container contentPane=getContentPane();
        contentPane.add(jPanel);
        //监听
        updateBtn.addActionListener(updateZooparkView1Handler);
        jPanel.add(updateBtn);

        setSize(350,500);
        setLocationRelativeTo(null);
        //DISPOSE_ON_CLOSE：只销毁当前的窗体
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setVisible(true);


    }

    public ZooparkEntity buildUpdatedZooparkEntity() {
        ZooparkEntity zooparkEntity=new ZooparkEntity();
        zooparkEntity.setId(Integer.valueOf(idTxt.getText()));
        zooparkEntity.setKind(kindTxt.getText());
        zooparkEntity.setIntroduction(introductionTxt.getText());
        zooparkEntity.setArea(areaTxt.getText());
        zooparkEntity.setAddress(addressTxt.getText());
        zooparkEntity.setBeginTime(Date.valueOf(beginTxt.getText()));
        zooparkEntity.setFinishTime(Date.valueOf(finishTxt.getText()));
        zooparkEntity.setAdminId(adminidTxt.getText());


        return zooparkEntity;
    }



}
